package com.umgsai.thread.thread58;

public class MyObject {
	private static MyObject myObject;
	private MyObject(){
	}
	public static MyObject getInstance() {
		//延迟加载
		if (myObject != null) {
			return myObject;
		}
		try {
			//模拟一个耗时操作
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		synchronized (MyObject.class) {
			if (myObject == null) {
				myObject = new MyObject();
			}
		}
		return myObject;
	}
}
